package agenceVoyageVirtuel.client.control;

import agenceVoyageVirtuel.client.Agence_voyage_virtuel;
import agenceVoyageVirtuel.client.beans.PackData;
import agenceVoyageVirtuel.client.viewer.DetailPackViewer;
import agenceVoyageVirtuel.client.viewer.ListPacksViewer;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;

public class ZoneDeTravail extends Composite {
	private ListPacksViewer listPacksViewer;
	private final Agence_voyage_virtuel agence_voyage_virtuel;
	private DetailPackViewer detailPackViewer;
	private DockPanel dockPanel;
	

	public ZoneDeTravail(Agence_voyage_virtuel agence_voyage_virtuel) {
		this.agence_voyage_virtuel = agence_voyage_virtuel;

		dockPanel = new DockPanel();
		initWidget(dockPanel);
		dockPanel.setSize("100%", "100%");
		listPacksViewer = new ListPacksViewer(this);
		dockPanel.add(listPacksViewer,DockPanel.CENTER);
	}

	public void selectPack(PackData pack) {
		dockPanel.remove(listPacksViewer);
		Label label = new Label("Chargement du pack...");
		dockPanel.add(label,DockPanel.NORTH);
		detailPackViewer = new DetailPackViewer(this,pack);
		dockPanel.remove(label);
		dockPanel.add(detailPackViewer,DockPanel.CENTER);
	}
	
	public void selectdefaultView(){
		selectListPacksViewer();
	}

	public void selectListPacksViewer() {
		dockPanel.clear();
		dockPanel.add(listPacksViewer,DockPanel.CENTER);
	}

	public ListPacksViewer getListPacksViewer() {
		return listPacksViewer;
	}
	
	public DetailPackViewer getDetailPackViewer() {
		return detailPackViewer;
	}

	public boolean isLogged() {
		return agence_voyage_virtuel.isLogged();
	}

	public void changeToLogged() {
		if(detailPackViewer!=null) 
			detailPackViewer.changeToLogged();
	}

	public void changeToNotLogged() {
		if(detailPackViewer!=null)
			detailPackViewer.changeToNotLogged();
	}
}
